package twu.shubham.biblioteca;
import java.util.Scanner;

public class biblioteca {

    public static void main(String args[]){

        int totalbooks=5;
        int continue1=1;
        bookrecord[] booklist = new bookrecord[totalbooks];
        int selectmenu ;
        for(int i=0; i<totalbooks; i++){
            booklist[i] = new bookrecord();
        }

        booklist[0].setValues(1,2,"a");
        booklist[1].setValues(2,0,"b");
        booklist[2].setValues(3,1,"c");
        booklist[3].setValues(4,4,"d");
        booklist[4].setValues(5,5,"e");

        System.out.println("Welcome to Library system");

        while(continue1==1)
        {
        System.out.println("Menu : \n1.See all the books\n2.Return a book\n3.See the membership detail\n enter an option");

        Scanner input = new Scanner( System.in );

        selectmenu = input.nextInt();
        if(selectmenu == 1)
        {
            for(int i=0;i<totalbooks;i++)

            {
                System.out.println(i+1 +"\t" + booklist[i].bookname);
            }

            System.out.println("Want to reserve a book : 1.Yes\n2.No\n");
            int reservebook;
            reservebook = input.nextInt();
            if(reservebook==1)
            {
                int booknumber;
                System.out.println("Enter the book number : ");
                booknumber = input.nextInt();

                if(booknumber<=totalbooks && booknumber-1>=0)
                {

                    if(booklist[booknumber-1].getAmtLeft()==1)
                    {
                        System.out.println("Thank You, Your book has been reserved\n");
                        booklist[booknumber-1].amt= booklist[booknumber-1].amt-1;
                    }

                    else
                    {
                        System.out.println("This book is not available yet\n");
                    }
                }

                else
                {
                    System.out.println("Not a Valid book number\n");
                }
            }


        }

        if(selectmenu==2)
        {
            System.out.println("Enter the book number");
            int booknumber;
            booknumber=input.nextInt();
            if(booklist[booknumber-1].getAct()==1)
            {
                System.out.println("Thank you for returning the book");
                booklist[booknumber-1].amt =booklist[booknumber-1].amt+1;
            }

            else
            {
                System.out.println("Sorry, we can't accept the book");
            }

        }
            if(selectmenu==3)
            {
                System.out.println("Contact Librarian\n");
            }

            System.out.println("Do You want to continue : 1.Yes\t2.No\n");
            continue1=input.nextInt();

        }




    }

}

